/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package csci6450.chickenFriedFS.nuggetServer.threads;

import csci6450.chickenFriedFS.nuggetServer.NuggetServer;
import csci6450.chickenFriedFS.nuggetServer.NuggetServerLog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;

/**
 *
 * @author jacobschoen
 */
public class MetaCheckInListener implements ActionListener {


    Timer timer;

    public MetaCheckInListener() {
        super();
    }

    public void setTimer(Timer set){
        this.timer = set;
    }

    public void actionPerformed(ActionEvent e) {
        NuggetServerLog.getInstance().reset();
        System.out.println("Meta Server ran off with the Chickens. Going to find them.");
        while (!NuggetServer.getInstance().registerWithMetaServer()){
            System.out.println("I feel lost with them!");
        }
        System.out.println("The Meta Server is back up. I am going to get a some chicken nuggets!");
    }

    private void stopTimer(){
        if(this.timer != null){
            this.timer.stop();
        }
    }

    public void reset(){
        this.timer.restart();
    }



}
